package com.beidasoft.web.util.enums;

/**
 * @Author songff
 * @MethodName
 * @Description //TODO 当事人类型字段转化
 * @Date 17:38 2020/3/26
 * @Param
 * @return 个人 10 - 1
 * 个体工商户 20 - 4
 * 法人 30 - 2
 * 非法人组织 40 - 3
 * 其他 90 - 9
 **/
public enum PartyTypeEnum {

    PARTY_TYPE_10("10", 1, "个人"),
    PARTY_TYPE_20("20", 4, "个体工商户"),
    PARTY_TYPE_30("30", 2, "法人"),
    PARTY_TYPE_40("40", 3, "非法人组织"),
    PARTY_TYPE_90("90", 9, "其他");

    private String code;//检查代码值
    private Integer type;//处罚代码值
    private String name;

    public String getCode() {
        return code;
    }

    public Integer getType() {
        return type;
    }

    public String getName() {
        return name;
    }

    PartyTypeEnum(String code, Integer type, String name) {
        this.code = code;
        this.type = type;
        this.name = name;
    }

    /**
     * @return java.lang.Integer
     * @Author songff
     * @MethodName getTypeByCode
     * @Description //TODO 通过处罚当事人代码值，获取检查当事人代码值
     * @Date 21:26 2020/3/26
     * @Param [code]
     **/
    public static Integer getTypeByCode(String code) {
        switch (code) {
            case "10":
                return PARTY_TYPE_10.type;
            case "20":
                return PARTY_TYPE_20.type;
            case "30":
                return PARTY_TYPE_30.type;
            case "40":
                return PARTY_TYPE_40.type;
            case "90":
                return PARTY_TYPE_90.type;
            default:
                return null;
        }
    }

    /**
     * @return java.lang.String
     * @Author songff
     * @MethodName getCodeByType
     * @Description //TODO 通过检查当事人代码值，获取处罚当事人代码值
     * @Date 21:27 2020/3/26
     * @Param [type]
     **/
    public static String getCodeByType(Integer type) {
        switch (type) {
            case 1:
                return PARTY_TYPE_10.code;
            case 2:
                return PARTY_TYPE_30.code;
            case 3:
                return PARTY_TYPE_40.code;
            case 4:
                return PARTY_TYPE_20.code;
            case 9:
                return PARTY_TYPE_90.code;
            default:
                return null;
        }
    }

    /**
     * @return java.lang.String
     * @Author songff
     * @MethodName getNameByTypeOrCode
     * @Description //TODO  通过检查或者处罚的当事人类型代码，获取当事人中文代码值
     * @Date 11:56 2020/3/27
     * @Param [type]
     **/
    public static String getNameByTypeOrCode(Object type) {
        switch (String.valueOf(type)) {
            case "1":
            case "10":
                return PARTY_TYPE_10.name;
            case "2":
            case "30":
                return PARTY_TYPE_30.name;
            case "3":
            case "40":
                return PARTY_TYPE_40.name;
            case "4":
            case "20":
                return PARTY_TYPE_20.name;
            case "9":
            case "90":
                return PARTY_TYPE_90.name;
            default:
                return null;
        }
    }
}
